﻿using Common.Communal;
using MediatR;
using System.Api.Write.Applocations.Commands.Organizes;
using System.Services.Organizes;

namespace System.Api.Write.Applocations.CommandHandlers.Organizes
{
    /// <summary>
    /// 删除组织机构命令处理程序
    /// </summary>
    public class OrganizeDeleteCommandHandler : IRequestHandler<OrganizeDeleteCommand, ApiResult<int>>
    {
        /// <summary>
        /// 组织机构服务
        /// </summary>
        private readonly IOrganizeService service;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="service">组织机构服务</param>
        public OrganizeDeleteCommandHandler(IOrganizeService service)
        {
            this.service = service;
        }

        /// <summary>
        /// 组织机构服务
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns>返回结果</returns>
        public Task<ApiResult<int>> Handle(OrganizeDeleteCommand request, CancellationToken cancellationToken)
        {
            return service.Delete(request.Id);
        }
    }
}
